/*
 * Copyright (c) 2023 by Kang Wang. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.egolessness.destino.core.storage.sql;

import org.egolessness.destino.common.model.Page;
import org.egolessness.destino.common.model.Pageable;
import org.egolessness.destino.core.fixedness.SnapshotOperation;
import org.egolessness.destino.core.model.Condition;
import org.egolessness.destino.core.storage.SnapshotProcessorAware;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

/**
 * interface of sql storage
 *
 * @author zsmjwk@outlook.com (wangkang)
 */
public interface SqlStorage extends SnapshotOperation {

    ResultSet select(String where) throws SQLException;

    <T> Page<T> page(List<Condition> conditions, String orderBy, Pageable pageable, Function<ResultSet, T> mappingFunc) throws SQLException;

    long count(String where) throws SQLException;

    void reload(List<Map<String, Object>> list) throws SQLException;

    void merge(Map<String, Object> data, String matched, String where) throws SQLException;

    void delete(List<Condition> conditions) throws SQLException;

    SnapshotProcessorAware getSnapshotProcessorAware();

}
